public  status_check
public  get_comma_string

ss4      segment     code
rseg    ss4



time_or_locat   bit     20h.5
gps_dat_vaild   bit     20h.6
lati_or_longti  bit     20h.7

one_lati        equ     40h
mten_lati       equ     41h
mone_lati       equ     42h


cxpos   equ     21h
cypos   equ     22h
str_loca_sms    equ     33h
comma_start     equ     35h
comma_content_size  equ 36h
comma_res_start equ     37h
which_comma     equ     38h


rev_buffer      equ     46h
tmp             equ     48h

;------------------------------------------------------------------------

status_check:
    push    1
    mov     comma_start, rev_buffer
    mov     which_comma,#02h
    mov     comma_res_start,#0a0h
    mov     comma_content_size,#00h
    call    get_comma_string
           
    mov     r1,comma_res_start
    mov     a,@r1
   

    cjne    a,#41h,exit_status_check                         ;41h=A means data valid
    setb    gps_dat_vaild
   


exit_status_check:
    

    pop     1

    ret
  

;------------------------------------------------------------------------   


;---------------------------------------------------------------------
;input: which_comma- String gets from which comma
;       comma_start-pointer to the beginning of a string
;       comma_content_size=0      
;output:comma_content_size-size of the content between two commas
;       comma_res_start the beginning address for keeping result

get_comma_string:
        push    1
        push    0
        mov     r0,comma_res_start
        mov     r2,which_comma
        mov     r1,comma_start
              
loop_get_comma_str: 
        mov     a,@r1          
        cjne    a,#2ch,next0_get_comma_str     ;2ch equals to ','
        djnz    r2,next1_get_comma_str



get_num_sat:
        inc     r1
        mov     a,@r1
        cjne    a,#2ch,next2_get_comma_str     ;2ch equals to ','
        sjmp    exit_get_comma_str

             


next0_get_comma_str:
        inc     r1
        cjne    r1,#9fh,loop_get_comma_str     ;the end of the string 9fh (address)

next1_get_comma_str:
        inc     r1
        sjmp    loop_get_comma_str

next2_get_comma_str:
        mov     @r0,a
        inc     r0
        inc     comma_content_size
        sjmp    get_num_sat



exit_get_comma_str:
        pop     0
        pop     1
        ret


;----------------------------------------------------------------------

end 